<?php
/**
 * Created by PhpStorm.
 * User: itboye
 * Date: 2016/10/26
 * Time: 17:48
 */
namespace Admin\Api;
use \Common\Api\Api;
use Admin\Model\GoodsFeedbackModel;

class PicSearchApi extends Api{
    const QUERY="Admin/PicSearch/query";

    const QUERYNOPAGING="Admin/PicSearch/queryNoPaging";

    const ADD="Admin/PicSearch/add";

    const DELETE="Admin/PicSearch/delete";

    const SAVE="Admin/PicSearch/save";

    const SAVE_BY_ID="Admin/PicSearch/saveById";

    const QUERY_VIEW="Admin/PicSearch/queryView";

    const GET_INFO="Admin/PicSearch/getInfo";

    protected function _init(){
        $this->model = new GoodsFeedbackModel();
    }
    public function query($map = null, $page = array('curpage' => 0, 'size' => 10), $order = false, $params = false, $fields = false)
    {
        $list = $this->model->alias('g')
            ->field('g.id,g.desc,g.img_url_list,g.contact_addr,g.uid,g.op_status,u.username')
            ->join('__UCENTER_MEMBER__ as u ON g.uid = u.id')
            ->where($map)
            ->order('create_time')
            ->page($page['curpage'],$page['size'])
            ->select();
        if ($list === false) {
            $error = $this->model->getDbError();
            return $this->apiReturnErr($error);
        }
        $count = $this->model->alias('g')
            ->field('g.id,g.desc,g.uid,g.op_status,u.username')
            ->join('__UCENTER_MEMBER__ as u ON g.uid = u.id')
            ->where($map)
            ->order('create_time')
            ->count();
        $Page = new \Think\Page($count);// 实例化分页类 传入总记录数和每页显示的记录数
        foreach($map as $key=>$val) {
            $Page->parameter[$key]   =   urlencode($val);
        }
        $show = $Page->show();
        return $this->apiReturnSuc(array("show" => $show, "list" => $list));
    }
}